<%@ page contentType="text/html;charset=UTF-8" %>
<%@include file="/WEB-INF/jsp/common/taglibs.jspf"%>
<es:contentHeader/>
<div class="page-content" data-state="${state}" data-state-info="${state.info}">
    <div class="page-header no-border no-margin">
        <ul class="nav nav-tabs">
            <c:forEach items="${states}" var="s">
                <c:if test="${s ne 'delete_box'}">
                    <li ${s eq state ? 'class="active"' : ''}>
                        <a href="${ctx}/admin/personal/message/${s}/list">
                            <i class="icon-table"></i>${s.info}
                        </a>
                    </li>
                </c:if>
            </c:forEach>
        </ul>
        <es:showMessage/>
    </div>
    <div class="row">
        <div class="col-sm-6 btn-group">
            <button type="button" id="btnCreate" class="btn btn-sm no-disabled">
                <i class="ace-icon fa fa-mail-forward"></i>发送新消息
            </button>
            <c:if test="${state eq 'in_box'}">
                <a class="btn btn-sm btn-mark-read">
                    <i class="ace-icon fa fa-flag"></i>标记为已读
                </a>
            </c:if>
            <c:if test="${state ne 'draft_box' and state ne 'store_box' and state ne 'trash_box'}">
                <a class="btn btn-sm btn-store">
                    <i class="ace-icon fa fa-star"></i>收藏
                </a>
            </c:if>
            <c:if test="${state eq 'trash_box'}">
                <a class="btn btn-sm btn-store">
                    <i class="ace-icon fa fa-undo"></i>恢复到收藏箱
                </a>
            </c:if>
            <a class="btn btn-sm btn-recycle-or-delete"><i class="ace-icon fa fa-trash"></i>删除</a>
            <a class="btn btn-sm no-disabled btn-clear">
                <i class="ace-icon fa fa-battery-empty"></i>清空${state.info}
            </a>
        </div>
        <div class="col-sm-6 text-right" style="padding-top:8px;padding-bottom:8px">
            <c:if test="${state eq 'in_box' or state eq 'out_box'}">
                提示:${state.info}超过365天的消息将被移到垃圾箱, 请将要保存的消息移到收藏箱
            </c:if>
            <c:if test="${state eq 'trash_box'}">
                提示: 系统会自动清除垃圾箱里超过30天的短信
            </c:if>
        </div>
    </div>
    <div class="row">
        <div class="col-xs-12 widget-container-col ui-sortable">
            <div class="widget-box widget-color-blue ui-sortable-handle" data-table="table">
                <div class="widget-header">
                    <h5 class="widget-title bigger lighter">
                        <i class="ace-icon fa fa-table"></i> 列表
                    </h5>
                </div>
                <div class="widget-body">
                    <div class="widget-main no-padding table_area">
                        <table id="table" class="sort-table table table-bordered table-hover" data-async="true">
                            <thead>
                            <tr>
                                <th style="width: 80px">
                                    <a class="check-all" href="javascript:void(0);">全选</a>|
                                    <a class="reverse-all" href="javascript:void(0);">反选</a>
                                </th>
                                <th sort="title">标题</th>
                                <c:if test="${state ne 'out_box'}">
                                    <th style="width: 100px" sort="senderId">发件人</th>
                                </c:if>
                                <c:if test="${state ne 'in_box'}">
                                    <th style="width: 100px" sort="receiverId">收件人</th>
                                </c:if>
                                <th style="width: 150px">发送时间</th>
                            </tr>
                            </thead>
                            <tbody>
                            <c:if test="${page.list.isEmpty()}">
                                <tr>
                                    <td class="empty" colspan="5">暂无数据</td>
                                </tr>
                            </c:if>
                            <c:forEach items="${page.list}" var="m">
                                <tr>
                                    <td class="check"><input type="checkbox" name="ids" value="${m.id}"></td>
                                    <td>
                                        <c:choose>
                                            <c:when test="${state eq 'draft_box'}">
                                                <a href="${ctx}/admin/personal/message/draft/${m.id}/send" class="btn btn-link no-padding">${m.title}</a>
                                            </c:when>
                                            <c:otherwise>
                                                <a href="${ctx}/admin/personal/message/${m.id}" class="btn btn-link no-padding">${m.title}</a>
                                                <c:if test="${m.read eq false}">
                                                    <span class="label label-important">未读</span>
                                                </c:if>
                                            </c:otherwise>
                                        </c:choose>
                                    </td>
                                    <c:if test="${state ne 'out_box'}">
                                        <td><sys:showUsername id="${m.senderId}"/></td>
                                    </c:if>
                                    <c:if test="${state ne 'in_box'}">
                                        <td><sys:showUsername id="${m.receiverId}"/></td>
                                    </c:if>
                                    <td><spring:eval expression="m.sendDate"/></td>
                                </tr>
                            </c:forEach>
                            </tbody>
                        </table>
                    </div>
                    <div class="widget-toolbox padding-8 clearfix">
                        <es:page page="${page}"/>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<es:contentFooter>
<%@include file="/WEB-INF/jsp/common/admin/import-personal-js.jspf"%>
<%@include file="/WEB-INF/jsp/common/import-editor-js.jspf"%>
<script type="text/javascript">
    $(function() {
        //$.personal.message.initBtn();
        $('#btnCreate').on('click', function(){
            $.app.layerIndex = $.app.openDialog(
                '发送消息',
                ctx + '/admin/personal/message/send',
                {area: ['600px', '500px']}
            );
        });
    });
</script>
</es:contentFooter>

